<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Менеджер фотографий
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	AdminView
 * @filename item_list.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
 
defined('_VALID_MOS') or die(); 

//Загружаем FancyBox
if ($params->get('adm_img_list_thumbs_fb')) {
    mosCommonHTML::loadJqueryPlugins('fancybox/jquery.fancybox',false, true);
}

?>

<!--Применение эскизов к категории -->
<script language="javascript" type="text/javascript">
  //Функция AJAX-смены эскиза категории
  function ch_thumb_cat(elID){
    $('#img-cat-'+elID).attr('src','images/aload.gif');
    $.get('ajax.index.php?option=com_joigallery&task=thumb_cat&id='+elID, function(data) {
          $('#img-cat-'+elID).attr('src','images/'+data);
    });
    return false;
  }
</script>


<form action="index2.php?option=<?php echo $option; ?>&act=photos" method="post" name="adminForm">
  <table class="adminheading">
    <tr>
      <th class="categories">
       <?php echo _C_JOIGALLERY_COMPONENT._C_JOIGALLERY_PHOTOS; ?>
      </th>      
      <td nowrap="nowrap" class="pl20"><?php echo '<font color="#999">'._C_JOIGALLERY_CATEGORY.':</font> ' ?><?php echo $lists['cid']; ?></td>
    </tr>
  </table>
  
  <table class="adminlist">
    <tr>
      <th width="10" class="acenter" style="text-align: center">#</th>
      <th width="20"><div class="checkbox" style="visibility:hidden"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count( $rows );?>);" /></div></th>
      <?php if ($params->get('adm_img_list_thumbs')) { ?>
        <th width="1" class="title acenter">
          <img src="<?php echo _JOI_GALLERY_ADMIN_SITE ?>/icons/photos.png"
               border="0" width="16" height="16" alt="" />
        </th>
      <?php }//if ?>
      <th class="title"><?php echo _C_JOIGALLERY_NAME ?></th>
      <th class="title"><?php echo _C_JOIGALLERY_CATEGORY ?></th>
      <th width="75" class="title" style="text-align: center"><?php echo _C_JOIGALLERY_PUBLISHED ?></th>	  
      <th width="2%" style="padding:0 5px 0 5px" colspan="2">
         <?php echo _C_JOIGALLERY_CATEGORY_ORDER ?>
      </th>      
      <th width="2%" class="nobl" >
           <a href="javascript: saveorder( <?php echo count( $rows )-1; ?> )">
             <img src="images/filesave.png" border="0" style="margin-left:5px;" width="16" height="16" alt="Сохранить" />
           </a>
      </th> 
      <th width="75" class="title acenter"><?php echo _C_JOIGALLERY_PHOTO_THUMB_CAT ?></th>
      <th width="20" style="text-align: center">ID</th>
    </tr>

  <?php
  $k = 0;
  for ($i=0, $n=count( $rows ); $i < $n; $i++) {
       $row  = &$rows[$i];
       $link = 'index2.php?option='.$option.'&amp;act=photos&amp;task=edit&amp;hidemainmenu=1&amp;cid='.$row->id;

       $icon_path = JPATH_SITE.'/'.JADMIN_BASE.'/templates/'.JTEMPLATE.'/images/ico';       
       $icon = $row->state ? 'publish_g.png' : 'publish_x.png';
       
	  
	   
	   if (empty($row->category)) {
	       $thumb_title = _C_JOIGALLERY_CATEGORY.' '. mb_strtolower(_C_JOIGALLERY_MSG_NOT_SET); 
	       $category_name = '<span class="red">'._C_JOIGALLERY_MSG_NOT_SET.'</span>';
	   }
	   else  $thumb_title = $category_name = $row->category;
	   	   
	   //Группировка изображений для просмотра в FancyBox
       if ($params->get('adm_img_list_thumbs_fb')) {  
            switch ($params->get('adm_img_list_thumbs_fb_group')) {
               case 'single':
                     $rel = '';//по одному
                     break;
               case 'cat':
                     $rel = 'rel="'.$row->cid.'"';//по категориям
                     break;
               case 'all':
                     $rel = 'rel="all"';//по порядку
                     break;
               default:
                     $rel = '';//по одному   
                     break;
			}		 
       }	
	   
       //Применение эскизов к категории
       $icon_cat = $row->default ? 'publish_g.png' : 'publish_x.png';
  ?>

    <tr class="row<?php echo $k; ?>" id="tr-el-<?php echo $row->id;?>">
      <td align="right"><?php echo $pageNav->rowNumber( $i ); ?></td>
      <td><div class="checkbox" style="visibility:hidden"><?php echo mosHTML::idBox($i, $row->id); ?></div></td>
      <?php if ($params->get('adm_img_list_thumbs')) { ?>
        <td>
          <div class="thumb_admin">		  
			<?php if ($params->get('adm_img_list_thumbs_fb')) { ?>
			  <a class="thumb" target="_blank" <?php echo $rel;?> href="<?php echo JPATH_SITE.$params->original_path.'/'.$row->path; ?>" title="<?php echo $thumb_title.'&nbsp;::&nbsp;'.$row->name; ?>">
                <?php    echo joiGalleryHelper::imgThumb ($thumb_source, $row->path, $params, 'item_list'); ?>
			  </a>
			<?php } else echo joiGalleryHelper::imgThumb ($thumb_source, $row->path, $params, 'item_list'); ?>
          </div>
        </td>
      <?php }//if ?>
      <td>
        <a href="<?php echo $link; ?>">         
          <?php echo $row->name; ?>
        </a>
      </td>      
      <td><?php echo $category_name; ?></td>
      <td align="center" <?php echo 'onclick="ch_publ('.$row->id.',\'com_joigallery\');" class="td-state"';?>>
	    <img class="img-mini-state" src="<?php echo $icon_path;?>/<?php echo $icon;?>" id="img-pub-<?php echo $row->id;?>" alt="<?php echo _PUBLISHING?>" />
      </td>
      <td><?php echo $pageNav->orderUpIcon( $i ); ?></td>
      <td><?php echo $pageNav->orderDownIcon( $i, $n ); ?></td>
      <td align="center">
        <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
      </td>      
	  <!--Применение эскизов к категории -->
      <td align="center" <?php echo 'onclick="ch_thumb_cat('.$row->id.');" class="td-state"';?>>
        <img class="img-mini-state" src="<?php echo $icon_path;?>/<?php echo $icon_cat;?>" id="img-cat-<?php echo $row->id;?>" alt="" />
      </td>
      <td align="right">
        <?php echo ($row->name) ? $row->id : '';?>
      </td>
    </tr>

    <?php
    $k = 1 - $k;
  }//for
  ?>
  </table>

  <div class="adminlistfooter">
   <?php echo $pageNav->getListFooter(); ?>
  </div>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="act" value="photos" />
  <input type="hidden" name="boxchecked" value="0" />  
  <input type="hidden" name="hidemainmenu" value="0" />
  
</form>

<script type="text/javascript">
  $(document).ready(function() {
    $("input").attr('autocomplete', 'off');//Убираем "autocomplete"    
    $(".checkbox").css('visibility', 'visible');
  });
  $("a.thumb").fancybox();
</script>